///**
// * 
// */
//package it.uniroma3.dia.digraph.algorithm.stackedTri;
//
//import it.uniroma3.dia.digraph.algorithm.Algorithm;
//import it.uniroma3.dia.digraph.algorithm.utility.kouterplanar.outerplanar.OuterplanarGraph;
//import it.uniroma3.dia.digraph.algorithm.utility.kouterplanar.outerplanar.OuterplanarNode;
//import it.uniroma3.dia.digraph.algorithm.utility.Utility;
//
//import java.util.Collection;
//import java.util.Collections;
//import java.util.Comparator;
//import java.util.InputMismatchException;
//import java.util.List;
//import java.util.Map;
//import java.util.Scanner;
//
//import org.graphdrawing.graphml.xmlns.GraphType;
//
///**
// * @author BarycentricCoords
// *
// */
//public class BarycentricCoords extends Algorithm {
//	
//	Map<Integer, List<OuterplanarNode>> depth2nodesSource, depth2nodesTarget;
//	OuterplanarGraph outerplanarSource;
//	GraphType source;
//	/* (non-Javadoc)
//	 * @see it.uniroma3.dia.digraph.algorithm.Algorithm#apply(org.graphdrawing.graphml.xmlns.GraphType[])
//	 */
//	@Override
//	public void apply(GraphType... inputGraphs) {
//		//check input
//		if (inputGraphs.length != 2)
//			throw new InputMismatchException("input must contain 2 graphs: source and target embeddings");
//
//		//initialise structures
//		this.init(inputGraphs);	
//		
//		//morph the graph
//		this.morph();
//		
//	}
//
//	/**
//	 * Morphs source graph to target graph
//	 */
//	private void morph() {
//		
//		List<OuterplanarNode> currentTargetLevel, currentSourceLevel;
//		
//		ComparatorById comparator = new ComparatorById();
//		OuterplanarNode currentSourceNode, currentTargetNode;
//		
////		displayLambda();
//		
//		//nodes on outer face don't move
//		for(OuterplanarNode on : depth2nodesSource.get(0))
//			on.setArrived(true);		
//		
//		// iterative deepening morphing 
//		for (int i=1; i<this.depth2nodesTarget.keySet().size(); i++ ){
//			System.out.println("morphing level "+i);
//			
//			//get source and target nodes at this depth
//			currentTargetLevel = this.depth2nodesTarget.get(i);
//			currentSourceLevel = this.depth2nodesSource.get(i);
//			
//			//sort both list to have corresponding elements at corresponding index
//			Collections.sort(currentTargetLevel, comparator);
//			Collections.sort(currentSourceLevel, comparator);
//			
//			//for each (source) node at this level, bring it to destination
//			for (int index=0; index<currentSourceLevel.size();index++){
//				
//				//get source and target node
//				currentSourceNode = currentSourceLevel.get(index);
//				currentTargetNode = currentTargetLevel.get(index);				
//				
//				//set source node position
//				currentSourceNode.getNode().setX(currentTargetNode.getNode().getX());
//				currentSourceNode.getNode().setY(currentTargetNode.getNode().getY());
//				currentSourceNode.getNode().setDefault(false);
//				currentSourceNode.setArrived(true);	
//				
//			}
////			displayLambda();
//			// nodes at depth greater than current must "follow" the movement
//			// of those at current depth
//			this.updateDeeperPositions(i);
//			displayLambda();
//			
////			//show new embedding
//			this.updateView();
//			new Scanner(System.in).nextLine();
//			
//		}
//		
//		
//	}
//	
//	private void displayLambda(){
//		for (Collection<OuterplanarNode> ns : this.depth2nodesSource.values()){
//			for (OuterplanarNode n : ns){
//				System.out.print(n.getId()+": "+n.getDepth()+" ");
//				for (OuterplanarNode p : n.getParents())
//					System.out.print(n.lambdas[n.getParents().indexOf(p)]+p.getId()+" ");
//				System.out.println();
//			}
//			
//		}
//		
//	}
//
//	/**
//	 * 
//	 * @param depth
//	 */
//	private void updateDeeperPositions(int depth) {
//		
//		for (OuterplanarNode current : this.outerplanarSource.getNodelist()){
//			
//			if (current.getDepth()>depth){
//				System.out.println(current.getId()+": "+current.getX()+" "+current.getY());
//				System.out.println(current.getId()+": "+current.getNode().getX()+" "+current.getNode().getY());
//				
//				
//				current.getNode().setX(current.getParentXCombination());
//				current.getNode().setY(current.getParentYCombination());
//				
//				
//				System.out.println(current.getId()+": "+current.getX()+" "+current.getY());
//				System.out.println(current.getId()+": "+current.getNode().getX()+" "+current.getNode().getY());
//			}
//		}
//		
//		
//	}
//
//	@Override
//	protected void init(GraphType... inputGraphs) {
//		
//		this.outerplanarSource = new OuterplanarGraph(inputGraphs[0]);
//		this.setGraph(inputGraphs[0]);
//		
//		this.depth2nodesSource = outerplanarSource.getNodes();
//		this.depth2nodesTarget = Utility.getDepthToNodes(inputGraphs[1]);	
//	}
//
//}
//

